//
//  HelpViewController.m
//  fugitive
//
//  Created by Eugene Bistolas on 5/26/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "HelpViewController.h"


@implementation HelpViewController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [dismissButton release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
   [self testServerFunctions]; 
}

- (void)viewDidUnload
{
    [dismissButton release];
    dismissButton = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction) dismissButton {
    [[self navigationController] setNavigationBarHidden:YES animated:YES];
    [self dismissModalViewControllerAnimated:YES];
   
}

- (void) testServerFunctions {
   int newInstance = (arc4random() % 999) + 1;
   
   [ServerEngine registerGameInformationWithInstance:newInstance endTime:5000 startLocation:CLLocationCoordinate2DMake(50.05, 150.05) stopLocation:CLLocationCoordinate2DMake(75, 22.3456)]; 
   [ServerEngine registerNewPowerupWithGameInstance:newInstance name:@"FUUUU" type:1 location:CLLocationCoordinate2DMake(50.3242, -23.456)]; 
   [ServerEngine registerNewPowerupWithGameInstance:newInstance name:@"BARRRRRR" type:2 location:CLLocationCoordinate2DMake(77.3242, -23.456)]; 

   
   int pid = [ServerEngine registerNewPlayerWithName:@"Eugene Bistolas" type:RUNNER gameInst:newInstance];
   ServerEngine *s = [[ServerEngine alloc] initWithPlayerID:pid playerType:RUNNER playerName:@"Eugene Bistolas" gameInstance:newInstance]; 
   
   [s updatePlayerLocation:CLLocationCoordinate2DMake(-50.005963, -150.345834)]; 

   [s getGameData]; 
   [s getInitialGameData]; 
   NSLog(@"endTime %d\n", s.endTime);
   NSLog(@"Start target: %f, %f\n", s.startTarget.coordinate.latitude, s.startTarget.coordinate.longitude); 
   NSLog(@"End target: %f, %f\n", s.endTarget.coordinate.latitude, s.endTarget.coordinate.longitude); 
   NSLog(@"Game running: %d\n", s.gameRunning); 
   NSLog(@"Game instance: %d\n", s.gameInstance); 
   
   
   for (Player *p in s.players) {
      NSLog(@"ID: %d\n", p.playerID);
      NSLog(@"Name: %@\n", p.playerName);
      NSLog(@"Type: %d\n", p.playerType);
      NSLog(@"Lat: %lf Lng: %lf", p.coordinate.latitude, p.coordinate.longitude); 
      NSLog(@"Alert: %d\n\n", p.alertStatus); 
   }
   
   NSLog(@"\nPOWERUPS!\n\n"); 
   for (Powerup *p in s.powerups) {
      NSLog(@"Type: %d\n", p.type);
      NSLog(@"ID: %d\n", p.powerupID); 
      NSLog(@"Lat: %lf Lng: %lf", p.coordinate.latitude, p.coordinate.longitude); 

   }
   
   [s release]; 
   
   
}

@end
